/**
 * 请求头
 */
export class NetHead {
  os: string = "web"
  ver: string = "1.0"
  channel: string = "hanz-perfect-life"
  token: string = "NOMUSTTOKEN"
  appId: string = "perfect-life"
  appSecret: string = "perfect-life-secret"
  lng: number = 121.123456
  lat: number = 31.123456
}

/**
 * 请求参数
 */
export class NetRequestBody<T> {
  head: NetHead
  param: T

  constructor(param: T) {
    this.head = new NetHead()
    this.param = param
  }

  static create<T>(param: T) {
    return new NetRequestBody(param)
  }
}

/**
 * 分页参数
 */
export class PageParam {
  page: number = 1
  pageSize: number = 10

  constructor(page: number, pageSize: number) {
    this.page = page
    this.pageSize = pageSize
  }

  static create(page: number, pageSize: number) {
    const pageParam = new PageParam(page, pageSize)
    return pageParam
  }
}

/**
 * 搜索排序分页参数
 */
export class SearchSortPageParam<S, O> {
  pageParam: PageParam;
  search: S;
  order: O

  constructor(pageParam: PageParam, search: S, order: O) {
    this.pageParam = pageParam
    this.search = search
    this.order = order
  }
  static create<S, O>(pageParam: PageParam, search: S, order: O) {
    return new SearchSortPageParam(pageParam, search, order)
  }
}

/**
 * 值返回结果
 */
export interface ValueResult<T> {
  value: T
}

/**
 * 分页返回结果
 */
export interface PageResult<T> {
  page: number,
  pageSize: number,
  total: number,
  hasNext: boolean,
  dataList: T[]
}

/**
 * ID参数
 */
export class IdParam<T> {
  id: T

  constructor(id: T) {
    this.id = id
  }
}
